package com.gyx.controller;

import com.gyx.entity.Userinfo;
import com.gyx.mapper.UserinfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @FileName: UserinfoController
 * @Description:
 * @Author: GYX
 * @CreateTime: 2024/12/19 10:51
 * @Version: 1.0.0
 */
@Controller
@RequestMapping("/userinfo")
public class UserinfoController {
    @Autowired
    private UserinfoMapper userinfoMapper;

    @RequestMapping("/login")
    public String login(String name, String password, HttpSession session) {
        Userinfo userinfo = userinfoMapper.selectByNameAndPwd(name, password);
        if (userinfo != null) {
            session.setAttribute("userinfo", userinfo);
            return "redirect:/emp/list";
        } else {
            return "forward:/login.jsp";
        }

    }
}
